{include file="public/header" /}
<span class="layui-breadcrumb">
  <a href="{:url('Blog/index')}?nav=blog-bloglist">产品</a>
  <a><cite>{if !empty($data_list['id']) }编辑{else/}添加{/if}产品</cite></a>
</span>
<style> 
.layui-form-label{width:200px;}
.layui-form-item .layui-input-block{margin-left:230px;}
</style>
<div class="layui-fluid">
    <div class="layui-card">
      <div class="layui-card-body">

        <div class="layui-form">
         <form class="layui-form" action="" id='product_form' style='padding:10px;'>
          {if empty($data_list['id']) }
          <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <div class="layui-input-block">
                <div style="color:red">
                  <p>Seo默认设置,在product_seo表中如下,在以后的批量接口上传中必须同时上传seo默认参数到该表,且顺序不能错</p>
                  <ul>
                    <li>title设置:part_number|分类|材质|Bearing_Type'|Lily Bearing'</li>
                    <li>关键词设置:part_number,分类,材质,Bearing_Type,'Lily Bearing Manufacturing,Bearings,lily bearing'</li>
                    <li>描述设置:'Lily Bearing manufactures' +材质+Bearing_Type+part_number</li>
                  </ul>
                </div>
            </div>
          </div>
          {/if}

          <div class="layui-form-item">
            <label class="layui-form-label">产品名称</label>
            <div class="layui-input-block">
                <input type="text" name="Part_Number" value="{if !empty($data_list['Part_Number']) }{$data_list['Part_Number']}{/if}" autocomplete="off" placeholder="请输入产品名称" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">选择品牌</label>
            <div class="layui-input-block">
              <select name="brand">
                <option value="0">请选择品牌</option>
                {volist name="sleinfo['brand']" id="data"}
                <option value="{$data.id}" {if !empty($data_list['brand_id']) }{if $data_list['brand_id']==$data.id}selected{/if}{/if}>{$data.bname}</option>
                {/volist}
              </select>
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">选择材质</label>
            <div class="layui-input-block">
              <select name="material">
                <option value="0">请选择材质</option>
                {volist name="sleinfo['material']" id="data"}
                <option value="{$data.id}" {if !empty($data_list['material_id']) }{if $data_list['material_id']==$data.id}selected{/if}{/if}>{$data.material}</option>
                {/volist}
              </select>
            </div>
          </div>
         
          <div class="layui-form-item">
            <label class="layui-form-label">选择分类</label>
            <div class="layui-input-block">
              <select name="quiz1" lay-filter="sel1">
                <option value="0">请选择分类</option>
                {volist name="sleinfo['classify']" id="data"}
                <option value="{$data['id']}"
                <?php 
                  if(!empty($data_list['classify'])){ 
                    $cl_count=count($data_list['classify']);
                    if($data_list['classify'][$cl_count-1]['xz']['id']==$data['id']){
                     echo "selected";
                    }
                  } 
                ?> 
                
                >{$data.cname}</option>
                {/volist}
              </select>
            </div>
            <div class="layui-input-block" style="margin-top:10px;{if !empty($data_list['classify']) }{if $cl_count>1 }display:block{/if}{else/}display:none{/if}">
              <select name="quiz2" id='quiz2' lay-filter="sel2">
                <option value="0">请选择分类</option>
                 {if !empty($data_list['classify']) }
                 {if $cl_count>1 }
                  {volist name="$data_list['classify'][$cl_count-2]['all']" id="data"}
                <option value="{$data['id']}" {if $data['id']==$data_list['classify'][$cl_count-2]['xz']['id'] }selected{/if}>{$data['cname']}</option>
                  {/volist}
                  {/if}
                {/if}
              </select>
            </div>
            <div class="layui-input-block" style="margin-top:10px;{if !empty($data_list['classify']) }{if $cl_count>2 }display:block{/if}{else/}display:none{/if}">
              <select name="quiz3" id='quiz3' lay-filter="sel3">
                <option value="0">请选择分类</option>
                {{if !empty($data_list['classify'])}
                {if $cl_count>2 }
                  {volist name="$data_list['classify'][$cl_count-3]['all']" id="data"}
                <option value="{$data['id']}" {if $data['id']==$data_list['classify'][$cl_count-3]['xz']['id'] }selected{/if}>{$data['cname']}</option>
                  {/volist}
                  {/if}
                {/if}
              </select>
            </div>

            <div class="layui-input-block" style="margin-top:10px;{if !empty($data_list['classify']) }{if count($data_list['classify']) >3 }display:block{else/}display:none{/if}{else/}display:none{/if}">
              <select name="quiz4" id='quiz4'>
                <option value="0">请选择分类</option>
                {if !empty($data_list['classify']) }
                {if $cl_count>3 }
                  {volist name="$data_list['classify'][$cl_count-4]['all']" id="data"}
                <option value="{$data['id']}" {if $data['id']==$data_list['classify'][$cl_count-4]['xz']['id'] }selected{/if}>{$data['cname']}</option>
                  {/volist}
                  {/if}
                {/if}
              </select>
            </div>
            
          </div>

          <div class="layui-form-item">
            <label class="layui-form-label">类型</label>
            <div class="layui-input-block">
                <input type="text" name="types" value="{if !empty($data_list['types']) }{$data_list['types']}{/if}" autocomplete="off" placeholder="请输入类型" class="layui-input">
            </div>
          </div>

          <div class="layui-form-item">
            <label class="layui-form-label">价格</label>
            <div class="layui-input-block">
                <input type="text" name="Price" value="{if !empty($data_list['Price']) }{$data_list['Price']}{/if}" autocomplete="off" placeholder="请输入价格" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">Bearing Type</label>
            <div class="layui-input-block">
                <input type="text" name="Bearing_Type" value="{if !empty($data_list['Bearing_Type']) }{$data_list['Bearing_Type']}{/if}" autocomplete="off" placeholder="请输入Bearing Type" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">For Load Direction</label>
            <div class="layui-input-block">
                <input type="text" name="For_Load_Direction" value="{if !empty($data_list['For_Load_Direction']) }{$data_list['For_Load_Direction']}{/if}" autocomplete="off" placeholder="请输入For Load Direction" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">Cross Section</label>
            <div class="layui-input-block">
                <input type="text" name="Cross_Section" value="{if !empty($data_list['Cross_Section']) }{$data_list['Cross_Section']}{/if}" autocomplete="off" placeholder="请输入Cross Section" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">Construction</label>
            <div class="layui-input-block">
                <input type="text" name="Construction" value="{if !empty($data_list['Construction']) }{$data_list['Construction']}{/if}" autocomplete="off" placeholder="请输入Construction" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">Contact Angle</label>
            <div class="layui-input-block">
                <input type="text" name="Contact_Angle" value="{if !empty($data_list['Contact_Angle']) }{$data_list['Contact_Angle']}{/if}" autocomplete="off" placeholder="请输入Contact Angle" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">Seal Type</label>
            <div class="layui-input-block">
                <input type="text" name="Seal_Type" value="{if !empty($data_list['Seal_Type']) }{$data_list['Seal_Type']}{/if}" autocomplete="off" placeholder="请输入Seal Type" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">For Shaft Diameter</label>
            <div class="layui-input-block">
                <input type="text" name="For_Shaft_Diameter" value="{if !empty($data_list['For_Shaft_Diameter']) }{$data_list['For_Shaft_Diameter']}{/if}" autocomplete="off" placeholder="请输入For Shaft Diameter" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">Bore Dia (d)</label>
            <div class="layui-input-block">
                <input type="text" name="Bore_Dia__d" value="{if !empty($data_list['Bore_Dia__d']) }{$data_list['Bore_Dia__d']}{/if}" autocomplete="off" placeholder="请输入Bore Dia (d)" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">Bore Dia Tolerance</label>
            <div class="layui-input-block">
                <input type="text" name="Bore_Dia_Tolerance" value="{if !empty($data_list['Bore_Dia_Tolerance']) }{$data_list['Bore_Dia_Tolerance']}{/if}" autocomplete="off" placeholder="请输入Bore Dia Tolerance" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">For Housing ID</label>
            <div class="layui-input-block">
                <input type="text" name="For_Housing_ID" value="{if !empty($data_list['For_Housing_ID']) }{$data_list['For_Housing_ID']}{/if}" autocomplete="off" placeholder="请输入For Shaft Diameter" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">Outer Dia (D)</label>
            <div class="layui-input-block">
                <input type="text" name="Outer_Dia__D" value="{if !empty($data_list['Outer_Dia__D']) }{$data_list['Outer_Dia__D']}{/if}" autocomplete="off" placeholder="请输入Outer Dia (D)" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">Outer Dia Tolerance</label>
            <div class="layui-input-block">
                <input type="text" name="Outer_Dia_Tolerance" value="{if !empty($data_list['Outer_Dia_Tolerance']) }{$data_list['Outer_Dia_Tolerance']}{/if}" autocomplete="off" placeholder="请输入Outer Dia Tolerance" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">Width (B)</label>
            <div class="layui-input-block">
                <input type="text" name="Width__B" value="{if !empty($data_list['Width__B']) }{$data_list['Width__B']}{/if}" autocomplete="off" placeholder="请输入Width (B)" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">Width Tolerance</label>
            <div class="layui-input-block">
                <input type="text" name="Width_Tolerance" value="{if !empty($data_list['Width_Tolerance']) }{$data_list['Width_Tolerance']}{/if}" autocomplete="off" placeholder="请输入Width Tolerance" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">Washer Material</label>
            <div class="layui-input-block">
                <input type="text" name="Washer_Material" value="{if !empty($data_list['Washer_Material']) }{$data_list['Washer_Material']}{/if}" autocomplete="off" placeholder="请输入Washer Material" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">Ring Material</label>
            <div class="layui-input-block">
                <input type="text" name="Ring_Material" value="{if !empty($data_list['Ring_Material']) }{$data_list['Ring_Material']}{/if}" autocomplete="off" placeholder="请输入Ring Material" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">Ball Material</label>
            <div class="layui-input-block">
                <input type="text" name="Ball_Material" value="{if !empty($data_list['Ball_Material']) }{$data_list['Ball_Material']}{/if}" autocomplete="off" placeholder="请输入Ball Material" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">Cage Material</label>
            <div class="layui-input-block">
                <input type="text" name="Cage_Material" value="{if !empty($data_list['Cage_Material']) }{$data_list['Cage_Material']}{/if}" autocomplete="off" placeholder="请输入Cage Material" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">Shield Material</label>
            <div class="layui-input-block">
                <input type="text" name="Shield_Material" value="{if !empty($data_list['Shield_Material']) }{$data_list['Shield_Material']}{/if}" autocomplete="off" placeholder="请输入Shield Material" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">Dynamic Load Rating(Cr)</label>
            <div class="layui-input-block">
                <input type="text" name="Dynamic_Load_Rating__Cr" value="{if !empty($data_list['Dynamic_Load_Rating__Cr']) }{$data_list['Dynamic_Load_Rating__Cr']}{/if}" autocomplete="off" placeholder="请输入Dynamic Load Rating Cr" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">Dynamic Thrust</label>
            <div class="layui-input-block">
                <input type="text" name="Dynamic_Thrust" value="{if !empty($data_list['Dynamic_Thrust']) }{$data_list['Dynamic_Thrust']}{/if}" autocomplete="off" placeholder="请输入Dynamic Thrust" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">Dynamic Thrust</label>
            <div class="layui-input-block">
                <input type="text" name="Dynamic_Moment" value="{if !empty($data_list['Dynamic_Moment']) }{$data_list['Dynamic_Moment']}{/if}" autocomplete="off" placeholder="请输入Dynamic Moment" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">Stati Load Rating(C0r)</label>
            <div class="layui-input-block">
                <input type="text" name="Static_Load_Rating__C0r" value="{if !empty($data_list['Static_Load_Rating__C0r']) }{$data_list['Static_Load_Rating__C0r']}{/if}" autocomplete="off" placeholder="请输入Stati Load Rating(C0r)" class="layui-input">
            </div>
          </div>
           <div class="layui-form-item">
            <label class="layui-form-label">Static Thrust</label>
            <div class="layui-input-block">
                <input type="text" name="Static_Thrust" value="{if !empty($data_list['Static_Thrust']) }{$data_list['Static_Thrust']}{/if}" autocomplete="off" placeholder="请输入Static Thrust" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">Static Moment</label>
            <div class="layui-input-block">
                <input type="text" name="Static_Moment" value="{if !empty($data_list['Static_Moment']) }{$data_list['Static_Moment']}{/if}" autocomplete="off" placeholder="请输入Static Moment" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">Maximum Speed Grease</label>
            <div class="layui-input-block">
                <input type="text" name="Maximum_Speed__Grease" value="{if !empty($data_list['Maximum_Speed__Grease']) }{$data_list['Maximum_Speed__Grease']}{/if}" autocomplete="off" placeholder="请输入Maximum_Speed__Grease" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">Maximum Speed Oil</label>
            <div class="layui-input-block">
                <input type="text" name="Maximum_Speed__Oil" value="{if !empty($data_list['Maximum_Speed__Oil']) }{$data_list['Maximum_Speed__Oil']}{/if}" autocomplete="off" placeholder="请输入Maximum Speed" class="layui-input">
            </div>
          </div>
           <div class="layui-form-item">
            <label class="layui-form-label">Reference Speed</label>
            <div class="layui-input-block">
                <input type="text" name="Reference_Speed" value="{if !empty($data_list['Reference_Speed']) }{$data_list['Reference_Speed']}{/if}" autocomplete="off" placeholder="请输入Reference Speed" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">Lubrication</label>
            <div class="layui-input-block">
                <input type="text" name="Lubrication" value="{if !empty($data_list['Lubrication']) }{$data_list['Lubrication']}{/if}" autocomplete="off" placeholder="请输入Lubrication" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">Lubricant</label>
            <div class="layui-input-block">
                <input type="text" name="Lubricant" value="{if !empty($data_list['Lubricant']) }{$data_list['Lubricant']}{/if}" autocomplete="off" placeholder="请输入Lubricant" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">Shaft Mount Type</label>
            <div class="layui-input-block">
                <input type="text" name="Shaft_Mount_Type" value="{if !empty($data_list['Shaft_Mount_Type']) }{$data_list['Shaft_Mount_Type']}{/if}" autocomplete="off" placeholder="请输入Shaft Mount Type" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">Temperature Range</label>
            <div class="layui-input-block">
                <input type="text" name="Temperature_Range" value="{if !empty($data_list['Temperature_Range']) }{$data_list['Temperature_Range']}{/if}" autocomplete="off" placeholder="请输入Temperature Range" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">ABEC Rating</label>
            <div class="layui-input-block">
                <input type="text" name="ABEC_Rating" value="{if !empty($data_list['ABEC_Rating']) }{$data_list['ABEC_Rating']}{/if}" autocomplete="off" placeholder="请输入ABEC Rating" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">Radial Clearance Trade No</label>
            <div class="layui-input-block">
                <input type="text" name="Radial_Clearance_Trade_No" value="{if !empty($data_list['Radial_Clearance_Trade_No']) }{$data_list['Radial_Clearance_Trade_No']}{/if}" autocomplete="off" placeholder="请输入Radial Clearance Trade No" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">Radial Clearance</label>
            <div class="layui-input-block">
                <input type="text" name="Radial_Clearance" value="{if !empty($data_list['Radial_Clearance']) }{$data_list['Radial_Clearance']}{/if}" autocomplete="off" placeholder="请输入Radial Clearance" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">Rohs</label>
            <div class="layui-input-block">
                <input type="text" name="Rohs" value="{if !empty($data_list['Rohs']) }{$data_list['Rohs']}{/if}" autocomplete="off" placeholder="请输入Rohs" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">Ball Qty</label>
            <div class="layui-input-block">
                <input type="text" name="Ball_Qty" value="{if !empty($data_list['Ball_Qty']) }{$data_list['Ball_Qty']}{/if}" autocomplete="off" placeholder="请输入Ball Qty" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">Ball Dia</label>
            <div class="layui-input-block">
                <input type="text" name="Ball_Dia" value="{if !empty($data_list['Ball_Dia']) }{$data_list['Ball_Dia']}{/if}" autocomplete="off" placeholder="请输入Ball Dia" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">Weight</label>
            <div class="layui-input-block">
                <input type="text" name="Weight" value="{if !empty($data_list['Weight']) }{$data_list['Weight']}{/if}" autocomplete="off" placeholder="请输入Weight" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">产品主图</label>
            <div class="layui-input-block">
              <div class="layui-upload">
              <button type="button" class="layui-btn layui-btn-xs" id="upload_img">选择图片</button>
              <span style='color:#FF5722;font-size:12px'>视频及ie8不支持预览</span>
              <div class="layui-upload-list">
                <img class="layui-upload-img" style='width:200px' id="show_img" src="{if !empty($data_list['img']) }{$data_list['img']}{/if}">
                <p id="demoText"></p>
              </div>
            </div> 
            </div>
            <input type="text" name="newname" style="display:none" value="{if !empty($data_list['img']) }{$data_list['img']}{/if}">
          </div>
          
          <div class="layui-form-item">
            <label class="layui-form-label">产品详情图</label>
            <div class="layui-input-block">
              <div class="layui-upload">
              <button type="button" class="layui-btn layui-btn-xs" id="dimg">选择图片</button>
              <span style='color:#FF5722;font-size:12px'>视频及ie8不支持预览</span>
              <div class="layui-upload-list">
                <img class="layui-upload-img" style='width:200px' id="show_d_img" src="{if !empty($data_list['dimg']) }{$data_list['dimg']}{/if}">
                <p id="demoText"></p>
              </div>
            </div> 
            </div>
            <input type="text" name="dimg" style="display:none" value="{if !empty($data_list['dimg']) }{$data_list['dimg']}{/if}">
          </div>
        
          <div class="layui-form-item">
            <label class="layui-form-label">产品pdf图</label>
            <div class="layui-input-block">
              <div class="layui-upload">
              <button type="button" class="layui-btn layui-btn-xs" id="upload_pdf">选择文件</button>
            </div> 
            </div>
            <div class="layui-input-block">
             <input type="text" name="pfile" readonly value="{if !empty($data_list['pfile']) }{$data_list['pfile']}{/if}" class="layui-input layui-disabled">
            </div>
          </div>
          
          <div class="layui-form-item" style='margin-top: 50px'>
            <label class="layui-form-label"></label>
            <div class="layui-input-block">
              <button type="button" class="layui-btn" onclick="insert_edit({if !empty($data_list['id']) }{$data_list['id']}{else/}'tj'{/if})">确 定</button>
            </div>
          </div>
          
        </form>

        </div>
      </div>  
    </div>
</div>

{include file="/public/footer" /}
<script>
  layui.use(['upload','form'], function(){
    var $ = layui.jquery
    ,upload = layui.upload;
    var form = layui.form;
  
    //主图图片上传
   var uploadInst = upload.render({
    elem: '#upload_img'
    ,accept: 'file'
    ,url: "{:url('Base/upload')}"+"?upload_url=static/upload/product/main/" //改成您自己的上传接口
    ,before: function(obj){
      //预读本地文件示例，不支持ie8
      obj.preview(function(index, file, result){
        $('#show_img').attr('src', result); //图片链接（base64）
      });
    }
    ,done: function(res){
      //如果上传失败
      if(res.status == '0'){
        return layer.msg(res.msg);
      }else{ //上传成功
        $("input[name='newname']").val(res.newname);
        return layer.msg(res.msg);
      }
    }
    ,error: function(){
      //演示失败状态，并实现重传
      var demoText = $('#demoText');
      demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
      demoText.find('.demo-reload').on('click', function(){
        uploadInst.upload();
      });
    }
  });

  var uploadInst = upload.render({
    elem: '#dimg'
    ,accept: 'file'
    ,url: "{:url('Base/upload')}"+"?upload_url=static/upload/product/detail/" //改成您自己的上传接口
    ,before: function(obj){
      //预读本地文件示例，不支持ie8
      obj.preview(function(index, file, result){
        $('#show_d_img').attr('src', result); //图片链接（base64）
      });
    }
    ,done: function(res){
      //如果上传失败
      if(res.status == '0'){
        return layer.msg(res.msg);
      }else{ //上传成功
        $("input[name='dimg']").val(res.newname);
        return layer.msg(res.msg);
      }
    }
    ,error: function(){
      //演示失败状态，并实现重传
      var demoText = $('#demoText');
      demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
      demoText.find('.demo-reload').on('click', function(){
        uploadInst.upload();
      });
    }
  });

  var uploadInst = upload.render({
    elem: '#upload_pdf'
    ,accept: 'file'
    ,url: "{:url('Base/upload')}"+"?upload_url=static/upload/product/pdf/" //改成您自己的上传接口 
    ,done: function(res){
      //如果上传失败
      if(res.status == '0'){
        return layer.msg(res.msg);
      }else{ //上传成功
        $("input[name='pfile']").val(res.newname);
        return layer.msg(res.msg);
      }
    }
    ,error: function(){
      //演示失败状态，并实现重传
      var demoText = $('#demoText');
      demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
      demoText.find('.demo-reload').on('click', function(){
        uploadInst.upload();
      });
    }
  });

  /*联动1*/
  form.on('select(sel1)', function(data){   
      var val=data.value;
      if(val=='0'){
        $("#quiz2").parent().css('display','none');
        $("#quiz2").html('');
        $("#quiz3").parent().css('display','none');
        $("#quiz3").html('');
        $("#quiz4").parent().css('display','none');
        $("#quiz4").html('');
        form.render('select');
        return false;
      }
      $.post("{:url('Classify/sel')}",{val:val},function(res){
          $("#quiz2").html(res);
          $("#quiz2").parent().css('display','block');
          form.render('select');
      })
  });
  /*联动2*/
  form.on('select(sel2)', function(data){   
      var val=data.value;
      if(val=='0'){
        $("#quiz3").parent().css('display','none');
        $("#quiz3").html('');
        $("#quiz4").parent().css('display','none');
        $("#quiz4").html('');
        form.render('select');
        return false;
      }
      $.post("{:url('Classify/sel')}",{val:val},function(res){
          $("#quiz3").html(res);
          $("#quiz3").parent().css('display','block');
          form.render('select');
      })
  });
  /*联动3*/
  form.on('select(sel3)', function(data){   
      var val=data.value;
      if(val=='0'){
        $("#quiz4").parent().css('display','none');
        $("#quiz4").html('');
        form.render('select');
        return false;
      }
      $.post("{:url('Classify/sel')}",{val:val},function(res){
          $("#quiz4").html(res);
          $("#quiz4").parent().css('display','block');
          form.render('select');
      })
  });
  
});  
</script>

<script>
  function insert_edit(id){

      layer.load();
      var x=$("#product_form").serialize();
      var Part_Number=$.trim($("input[name='Part_Number']").val());
      var quiz1=$.trim($("select[name='quiz1'] option:selected").val());
      var quiz2=$.trim($("select[name='quiz2'] option:selected").val());
      var quiz3=$.trim($("select[name='quiz3'] option:selected").val());
      var quiz4=$.trim($("select[name='quiz4'] option:selected").val());

      if(Part_Number==''){
          layer.closeAll('loading');
          $("input[name='Part_Number']").focus();
          layer.msg('请填写产品名称');
          return false;
      }
      
      if(quiz1=='0'||quiz1==''){
          layer.closeAll('loading');
          layer.msg('请选择分类');
          return false;
      }

      if(id=='tj'){
        var url="{:url('Product/do_change')}";
      }else{
        var url="{:url('Product/do_change')}"+"?id="+id;
      }
      $.post(url,x,function(res){
        if(res.status=='0'){
            layer.closeAll('loading');
            layer.msg(res.msg);
        }
        if(res.status=='1'){
            layer.msg(
            res.msg,{time: 1500 },
            function(){
              layer.closeAll();
              location.href=location.href;
            });
        }
    }) 
  }
</script>


